package com.tc.itfarm.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.tc.itfarm.dao.SingleTableMapper;
import com.tc.itfarm.dao.UserMapper;
import com.tc.itfarm.model.User;
import com.tc.itfarm.model.UserCriteria;
import com.tc.itfarm.service.UserService;

@Service
public class UserServiceImpl extends BaseServiceImpl<User> implements UserService {

	@Resource
	private UserMapper userMapper;

	@Resource(name="userMapper")
	public void setMapper(SingleTableMapper<User, ?> mapper) {
		super.setMapper(mapper);
	}
	
	public void save(User t) {
		if (t.getRecordId() == null) {
			this.insert(t);
		} else {
			this.update(t);
		}
	}
	
	@Override
	public List<User> selectAll() {
		UserCriteria example = new UserCriteria();
		return userMapper.selectByExample(example);
	}


}
